<template>
	<view>
		<u--textarea v-model="content.text" placeholder="分享你的新鲜事到社区与大家互动吧~" height='100px' count confirmType="done"
			style="padding: 10px; margin-bottom: 10px;"></u--textarea>
			
			<u-upload
			  :fileList="content.fileList"
			  @afterRead="afterRead"
			  @delete="deletePic"
			  :previewFullImage="true"
			  name="5"
			  multiple
			  :maxCount="9"
			></u-upload>
			
		<u-button type='success' text="发布" style="margin-top: 5px;" @click="issue()"></u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content: {
					text: '',
					fileList: [],
					userId: '111'
				}
			};
		},
		methods: {
			issue() {
				// this.content = this.content.trim()
				if (this.content.text.trim() == '') {
					this.content.text = ''
					console.log('not issur!')
					uni.showToast({
						title: '内容不能为空!',
						icon: 'error', 
						duration: 2000 // 提示信息显示的时间（毫秒）
					});
				} else {
					console.log('user issur: ', this.content)
					// 向后端传递内容,向数据库添加
					// ...
					
					// 发布后跳转到社区页
					
					uni.reLaunch({
						url: '/pages/community/index'
					});
				}
			}

		}
	}
</script>

<style lang="scss">

</style>